package com.teach.demo02;

/**
 * <pre>
 * -
 * Author : J.L.Zhou
 * E-Mail : 2233875735@qq.com
 * Tel : 151 1104 7708
 * Date : 2021-04-06 14:46
 * Version : 1.0
 * Copyright 2021 jlzhou.top Inc. All rights reserved.
 * Warning: this content is only for internal circulation of the company.
 *          It is forbidden to divulge it or use it for other commercial purposes.
 * </pre>
 **/
public class Test {
  public static void main(String[] args) {
    Student s1,s2;
    s1 = new Student();
    s1.setAge(20);
    s1.setName("张三");
    s1.school = "湖南XXXX学院";//静态成员变量不推荐使用实例对象来访问
    Student.school="湖南XXXX学院";//通常使用类名访问静态成员

    s2 = new Student();
    s2.setAge(22);
    s2.setName("李四");
    s2.setSchool("湖南大学");//不推荐
    Student.setSchool("湖南大学");//通常使用类名访问静态方法

    System.out.println(s1);
    System.out.println(s2);

    //思考
    Student s3 = null;
//    s3.setName("王五");//报错:NullPointerException
    s3.setSchool("国防科大");//能成功
  }
}
